<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@include file="/WEB-INF/jsp/include/tags.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>inventory - list</title>
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<script type="text/javascript">
	<!--
		function goPage(page) {
			var f = document.inventoryCriteriaForm;
			f.action = '/inventory.do';
			f.method = 'get';
			f.elements["mode"].value = "list";
			f.elements["paging.currentPage"].value = page;
			f.submit();
		}
		
		function search() {
			var f = document.inventoryCriteriaForm;
			f.action = '/inventory.do';
			f.method = 'get';
			f.elements["mode"].value = "list";
			f.elements["paging.currentPage"].value = 0;
			f.submit();
		}
		
		function goDetail(itemid) {
			var f = document.inventoryCriteriaForm;
			f.action = '/inventory.do';
			f.method = 'get';
			f.elements["mode"].value = "detail";
			f.elements["itemid"].value = itemid;
			f.submit();
		}
		
		function goWrite() {
			var f = document.inventoryCriteriaForm;
			f.action = '/inventoryWrite.do';
			f.method = 'get';
			f.elements["mode"].value = "write";
			f.submit();
		}
	//-->
	</script>
</head>
<body>

	<p>
		<a href="/">home</a>
	</p>

	<h1>Inventory - list</h1>

	<form:form commandName="inventoryCriteria" id="inventoryCriteriaForm"
		name="inventoryCriteriaForm" action="/inventory.do" method="get">
		<input type="hidden" name="mode" />
		<form:hidden path="itemid" />
		<form:hidden path="paging.currentPage" />
	</form:form>

	<div>${inventoryCriteria.paging.totalResults} results.</div>

	<table width="800">
		<colgroup width="800">
			<col width="*" />
			<col width="*" />
		</colgroup>
		<tr>
			<th>itemid</th>
			<th>qty</th>
		</tr>
		<c:forEach var="inventory" items="${inventoryList}">
			<tr>
				<td><a href="javascript:goDetail('${inventory.itemid}');">
						<c:out value="${inventory.itemid}" />
				</a></td>
				<td><c:out value="${inventory.qty}" /></td>
			</tr>
		</c:forEach>
	</table>

	<div>
		<c:set var="paging" value="${inventoryCriteria.paging}" />
		<%@ include file="/WEB-INF/jsp/include/paging/default.jsp"%>
	</div>

	<p />

	<a href="<c:url value='javascript:goWrite();'/>">write</a>
	<a href="<c:url value='/inventory.do'/>">list</a>

</body>
</html>
